home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 589 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.6 KB

  1. From: kj7bg@primenet.com (Bob White)
  2. Message-ID: <4h2mlp$s3c@nnrp1.news.primenet.com>
  3. X-Original-Date: 28 Feb 1996 15:58:01 -0700
  4. Path: in1.uu.net!bounce-back
  5. Date: 29 Feb 96 06:23:53 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Namespaces within class definition???
  9. Organization: Primenet Services for the Internet
  10. References: <4h27pi$ejv@nnrp1.news.primenet.com> <4h2ajf$l69@engnews1.Eng.Sun.COM>
  11. X-Posted-By: ip172.boi.primenet.com
  12. X-Newsreader: WinVN 0.99.6
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMTVHQuEDnX0m9pzZAQE8LgF/T7W4SOKtMmbFjJwQ8OlOaELuD01bu8Bc
  15.     IkXQrHXjG9kpHjI03LY0NKCl8H5rH8xh
  16.     =XXN9
  17.  
  18. Thanks for the fast response.  I guess Microsoft has a bug which I will let 
  19. them know about.  I tried the following and it seems to work:
  20.  
  21. typedef    std::string XyzString;
  22. class xyz : public XyzString { }
  23.  
  24. So I will use it until Borland and Microsoft allow me the more 
  25. straight forward way.  Also, I am using the "string" class as defined by one 
  26. version of the C++ standard which was put in the "std" namespace.  I thought
  27. this was what the current standard required!   Maybe that's what I get for
  28. thinking.  Anyway, thanks for the help!
  29.  
  30. [Moderator's note: remainder of article contains only quoted text. -fjh.]
  31.  
  32. In article <4h2ajf$l69@engnews1.Eng.Sun.COM>, clamage@Eng.Sun.COM says...
  33. >
  34. >In article ejv@nnrp1.news.primenet.com, kj7bg@primenet.com (Bob White) 
  35. writes:
  36. >
  37. >>Assuming that the "string" class is properly defined in namespace "std", is 
  38. it 
  39. >>legal to do the following:
  40. >
  41. >>class xyz : public std::string {
  42. >>}
  43. >
  44. >>I am trying to do this with Visual C++ v4.0 and it is giving me an INTERNAL 
  45. >>COMPILER ERROR.  I thought that this was legal syntax, but am not certain.
  46. >>Thanks in advance for your help.
  47. >
  48. >Yes, it's valid. Sounds like growing pains regarding a new language feature.
  49. >
  50. >Try this as a workaround:
  51. >
  52. >        using std::string;
  53. >        class xyz : public string { ... };
  54. >
  55. >The difference is that std::string is now placed in the current scope 
  56. >as "string", which might collide with other names in the program.
  57. >Ideally, you will abandon "string" as a user identifier because it is
  58. >the name of a standard class. Using "string" for other purposes
  59. >will be confusing and make future maintenance more difficult.
  60. >---
  61. >Steve Clamage, stephen.clamage@eng.sun.com
  62.  
  63. ---
  64. [ To submit articles: try just posting with your news-reader.
  65.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  66.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  67.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  68.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  69. ]
  70.